﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FWMS.DAO
{
    class CailiaoChooseDAO
    {
        //页面初始化查询数据
        public Bean.CailiaoChooseBean cailiaoChooseDaoSelectCondition()
        {
            bool cailiaonameflag = false;
            DB.DBbase dbbase = new DB.DBbase();
            Bean.CailiaoChooseBean bean = new FWMS.Bean.CailiaoChooseBean();
            string yuancailiaosql = "";
            string tiaoweiliaosql = "";
            string fuliaosql = "";
            yuancailiaosql = "select * from cailiaoguanli where cailiaotype = '原料'";
            tiaoweiliaosql = "select * from cailiaoguanli where cailiaotype = '调味料'";
            fuliaosql = "select * from cailiaoguanli where cailiaotype = '辅料'";
            if(dbbase.ExecuteSQL(yuancailiaosql.Trim()))
            {
                if (dbbase.rows.Length != 0)
                {
                    bean.YuancailiaoSelectresult = dbbase.rows;
                    bean.Yuancailiaorows = dbbase.Row_Number;
                }
                else
                {
                    bean.YuancailiaoSelectresult = null;
                    bean.Yuancailiaorows = 0;
                }
            }

            if (dbbase.ExecuteSQL(tiaoweiliaosql.Trim()))
            {
                if (dbbase.rows.Length != 0)
                {
                    bean.TiaoweiliaoSelectresult = dbbase.rows;
                    bean.Tiaoweiliaorows = dbbase.Row_Number;
                }
                else
                {
                    bean.TiaoweiliaoSelectresult = null;
                    bean.Tiaoweiliaorows = 0;
                }
            }

            if (dbbase.ExecuteSQL(fuliaosql.Trim()))
            {
                if (dbbase.rows.Length != 0)
                {
                    bean.FuliaoSelectresult = dbbase.rows;
                    bean.Fuliaorows = dbbase.Row_Number;
                }
                else
                {
                    bean.FuliaoSelectresult = null;
                    bean.Fuliaorows = 0;
                }
            }
            return bean;
        }
    }
}
